/*
 * Copyright (C) 2003, 2004 Rex Ford
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
package GamePlay;

public class Location {
	private double x;
	private double y;
	
	public Location(int over, int down) {
		y = (double)down;
		x = (double)over;
	}
	public Location(double over, double down){	
		y=down;
		x=over;
	}
	
	public double getX() {
		return x;
	}
	
	public double getY() {
		return y;
	}
	
	public void moveX(double mx){
		x+=mx;
	}
	
	public void moveY(double my){
		y+=my;
	}
	
	public void moveX(int mx){
		x+=mx;
	}
	public void moveY(int my){
		y+=my;
	}
	
	//these two should use rounding, not truncation. but I'm too tired right now
	public void setX(double xp){
		x=(int)xp;
	}
	
	public void setY(double yp){
		y=(int)yp;
	}
	
	public Location addLocs(Location other){
		double newX = other.getX()+x;
		double newY = other.getY()+y;
		return new Location(newX,newY);
	}
	public Location subtractLocs(Location other){
		double newX = x-other.getX();
		double newY = y-other.getY();
		return new Location(newX,newY);
	}
	public Location scale(double amount)
	{
		double newX=x*amount;
		double newY=y*amount;
		return new Location(newX,newY);
	}
	public boolean isInView()
	{
		int offset=40;
		return x<900+offset && x>-offset && y>-offset && y<700+offset;
	}
	
}
